<div ng-init="dvm.init()" class="x-security">
  <div class="modal-header">
    <button ng-if="accessible" type="button" class="close" ng-click="dvm.close()">&times;</button>
    <h4 class="modal-title">{{dvm.modalType == 'login' ? '登录' : (dvm.modalType == 'register' ? '注册' : '重置密码')}}</h4>
  </div>
  <div class="modal-body">
    <!-- login -->
    <form name="frmLogin" ng-submit="dvm.login(frmLogin.$valid)" ng-if="dvm.modalType == 'login'" novalidate>
      <fieldset>
        <div class="form-group">
          <input name="email" type="email" class="form-control" ng-model="dvm.email" placeholder="邮箱"
              required ng-class="{'x-invalid': frmLogin.$submitted && frmLogin.email.$invalid}" autofocus>
          <p class="text-danger" ng-show="frmLogin.$submitted && frmLogin.email.$error.required">邮箱不能为空</p>
        </div>
        <div class="form-group">
          <input name="password" type="password" class="form-control" ng-model="dvm.password" placeholder="密码"
              required ng-class="{'x-invalid': frmLogin.$submitted && frmLogin.password.$invalid}">
          <p class="text-danger" ng-show="frmLogin.$submitted && frmLogin.password.$error.required">密码不能为空</p>
        </div>
        <div class="checkbox">
          <label><input type="checkbox" ng-model="dvm.rememberMe"> 记住我一周</label>
        </div>
        <button type="submit" class="btn btn-default btn-block btn-lg" ng-disabled="frmLogin.$invalid">
          <i class="fa fa-sign-in"></i> 登录</button>
      </fieldset>
      <hr>
      <div class="row">
        <div class="col-xs-6">
          <a href="javascript:void(0)" ng-click="dvm.modalType = 'register'">&lt; 现在注册</a>
        </div>
        <div class="col-xs-6 text-right">
          <a href="javascript:void(0)" ng-click="dvm.modalType = 'reset'">忘记密码 &gt;</a>
        </div>
      </div>
    </form>
    <!-- register -->
    <form name="frmRegister" ng-submit="dvm.register(frmRegister.$valid)" ng-if="dvm.modalType == 'register'" novalidate>
      <fieldset>
        <div class="form-group">
          <input name="email" type="email" class="form-control" ng-model="dvm.email" placeholder="邮箱"
              required ng-class="{'x-invalid': frmRegister.$submitted && frmRegister.email.$invalid}" autofocus>
          <p class="text-danger" ng-show="frmRegister.$submitted && frmRegister.email.$error.required">邮箱不能为空</p>
        </div>
        <div class="form-group">
          <input name="password" type="password" class="form-control" ng-model="dvm.password" placeholder="密码"
              required ng-class="{'x-invalid': frmRegister.$submitted && frmRegister.password.$invalid}">
          <p class="text-danger" ng-show="frmRegister.$submitted && frmRegister.password.$error.required">密码不能为空</p>
        </div>
        <div class="form-group">
          <input name="cfmPassword" type="password" class="form-control" ng-model="dvm.cfmPassword" placeholder="确认密码"
              required ng-class="{'x-invalid': frmRegister.$submitted && frmRegister.cfmPassword.$invalid}">
          <p class="text-danger" ng-show="frmRegister.$submitted && frmRegister.cfmPassword.$error.required">确认密码不能为空</p>
          <p class="text-danger" ng-show="frmRegister.$submitted && dvm.cfmPassword && dvm.cfmPassword != dvm.password">两次输入的密码不一致</p>
        </div>
        <button type="button" class="btn btn-default btn-block" ng-disabled="!dvm.email || !dvm.kaptchaEnabled"
            ng-click="dvm.getKaptcha()">获取邮箱验证码{{dvm.kaptchaTimer}}</button>
        <div class="form-group" style="margin-top:-1px">
          <input name="kaptcha" type="text" class="form-control" ng-model="dvm.kaptcha" placeholder="验证码"
              required ng-class="{'x-invalid': frmRegister.$submitted && frmRegister.kaptcha.$invalid}">
          <p class="text-danger" ng-show="frmRegister.$submitted && frmRegister.kaptcha.$error.required">验证码不能为空</p>
        </div>
        <button type="submit" class="btn btn-default btn-block btn-lg" ng-disabled="frmRegister.$invalid">
          <i class="fa fa-user"></i> 注册</button>
      </fieldset>
      <hr>
      <div class="row">
        <div class="col-xs-6">
          <a href="javascript:void(0)" ng-click="dvm.modalType = 'login'">&lt; 账号登录</a>
        </div>
        <div class="col-xs-6 text-right">
          <a href="javascript:void(0)" ng-click="dvm.modalType = 'reset'">忘记密码 &gt;</a>
        </div>
      </div>
    </form>
    <!-- reset password -->
    <form name="frmReset" ng-submit="dvm.reset(frmReset.$valid)" ng-if="dvm.modalType == 'reset'" novalidate>
      <fieldset>
        <div class="form-group">
          <input name="email" type="email" class="form-control" ng-model="dvm.email" placeholder="邮箱"
              required ng-class="{'x-invalid': frmReset.$submitted && frmReset.email.$invalid}" autofocus>
          <p class="text-danger" ng-show="frmReset.$submitted && frmReset.email.$error.required">邮箱不能为空</p>
        </div>
        <div class="form-group">
          <input name="captcha" type="text" class="form-control" ng-model="dvm.captcha" placeholder="验证码"
              required ng-class="{'x-invalid': frmReset.$submitted && frmReset.captcha.$invalid}">
          <p class="text-danger" ng-show="frmReset.$submitted && frmReset.captcha.$error.required">验证码不能为空</p>
        </div>
        <div class="form-group x-captcha" ng-init="dvm.changeRandomId()">
          <img ng-src="{{'/mock/auth/captcha?id=' + dvm.randomId}}" ng-click="dvm.changeRandomId()" title="点击切换验证码">
        </div>
        <button type="submit" class="btn btn-default btn-block btn-lg" ng-disabled="frmReset.$invalid">
          <i class="fa fa-repeat"></i> 重置密码</button>
      </fieldset>
      <hr>
      <div class="row">
        <div class="col-xs-6">
          <a href="javascript:void(0)" ng-click="dvm.modalType = 'login'">&lt; 账号登录</a>
        </div>
        <div class="col-xs-6 text-right">
          <a href="javascript:void(0)" ng-click="dvm.modalType = 'register'">现在注册 &gt;</a>
        </div>
      </div>
    </form>
  </div>
</div>
